<template>
    <div class="app-container">

        <template>

            <div class="app-container">

                <h2 style="text-align: center;">公告详细信息</h2>
                <div class="ccInfo">
                    <div>
                        <img :src="annoInfo.image">
                    </div>
                    <div class="main">
                        <el-descriptions class="margin-top" title="" :column="1" direction="horizontal">
                            <el-descriptions-item label="公告标题">{{ annoInfo.title }}</el-descriptions-item>
                            <el-descriptions-item label="公告内容">{{ annoInfo.contentText }}</el-descriptions-item>
                            <el-descriptions-item label="阅读量">{{ annoInfo.viewCount }}</el-descriptions-item>
                            <el-descriptions-item label="时间">{{ annoInfo.gmtCreate }}</el-descriptions-item>
                        </el-descriptions>
                    </div>
                </div>


                <div>
                    <el-button @click="previous" class="shangyiye">返回上一页</el-button>
                    <el-button :disabled="saveBtnDisabled" class="queren" type="primary" @click="confirm">确认阅读公告</el-button>
                </div>
            </div>
        </template>

    </div>
</template>
  
<script>
import announcement from '@/api/announcement'
export default {
    data() {
        return {
            annoId: '',
            annoInfo: {
                title: '',
                contentText: '',
                image: '',
                priority: '',
                gmtCreate: '',
                viewCount: '',
            },
        }
    },
    created() {
        this.annoId = this.$route.params.id;
        this.getInfoAnno();
    },

    methods: {
        getInfoAnno() {
            // 根据id值获取信息
            announcement.selectInfo(this.annoId).then(response => {
                this.annoInfo = response.data.data.anno;
            })
        },
        confirm() {
            this.$confirm('此操作表示你已经阅读该条信息, 请确保已经仔细阅读该信息?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                announcement.confirm(this.annoId)
                    .then(response => {
                        // 提示信息
                        this.$message({
                            type: 'success',
                            message: 'ok'
                        });
                        this.getInfoAnno();
                    })
            })
        },
        previous(){
            this.$router.go(-1)
        },
    }
}
</script>

<style scoped>
.queren {
    float: right;
    margin-right: 40%;
}

.shangyiye {
    float: left;
    margin-left: 40%;
}

.ccInfo {
    background: #f5f5f5;
    padding: 20px;
    overflow: hidden;
    border: 1px dashed #DDD;
    margin-bottom: 40px;
    position: relative;
}

.ccInfo img {
    background: #d6d6d6;
    width: 500px;
    height: 278px;
    display: block;
    float: left;
    border: none;
}

.ccInfo .main {
    margin-left: 520px;
}

.ccInfo .main h2 {
    font-size: 28px;
    margin-bottom: 30px;
    line-height: 1;
    font-weight: normal;
}

.ccInfo .main p {
    margin-bottom: 10px;
    word-wrap: break-word;
    line-height: 24px;
    max-height: 48px;
    overflow: hidden;
}

.ccInfo .main p {
    margin-bottom: 10px;
    word-wrap: break-word;
    line-height: 24px;
    max-height: 48px;
    overflow: hidden;
}

.ccInfo .main h3 {
    left: 540px;
    bottom: 20px;
    line-height: 1;
    font-size: 28px;
    color: #d32f24;
    font-weight: normal;
    position: absolute;
}
</style>